using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ViewAllNotes : System.Web.UI.Page
{
    protected void Page_PreInit(object sender, EventArgs e)
    {
        this.Theme = Session["Theme"].ToString();
    }

    protected void Page_Load(object sender, EventArgs e)
   {
        security hdds = new security();
        if (Session["userid"] == null) Response.Redirect(hdds.SessionExpiryURL);
        if (Session["userid"].ToString() == "") Response.Redirect(hdds.SessionExpiryURL);

        //Code added by Sampath on 18-Nov-2011 for IPP Vertical privilege
        if (Request.QueryString["mn"] != null)
        {
            if (!hdds.checkObjectMenuAccess(Request.QueryString["mn"]))
            {
                tblcontrols.Visible = false;
                lblmessage.Text = wrapItAsMessage("<img src=\"Images/info.gif\" alt=\"\"></img>&nbsp;You do not have sufficient access permission.", true);
                return;
            }
        }
        //Code added by Sampath on 15-Nov-2011 for IPP Vertical privilege
        if (Request.QueryString["PK"] != null && Request.QueryString["pgs_id"] != null)
        {
            if (!hdds.checkRecordAccess(Request.QueryString["PK"].ToString(), Request.QueryString["pgs_id"].ToString()))
            {
                tblcontrols.Visible = false;
                lblmessage.Text = wrapItAsMessage("<img src=\"Images/info.gif\" alt=\"\"></img>&nbsp;You do not have sufficient access permission.", true);
            }
        }
        Navigator.storeURL(Request.Url.ToString(), IsPostBack, false, false); // Added by 'Imran Gani' on 25-May-2012, to Navigate URL.
        if (Request.QueryString["PK"] != null)
        {
            AddCancelButtons();
            
            HDDatabase Hdd = new HDDatabase();
            //DataTable dsPageInfo = new DataTable();
            AdditionalPageInfo addinfo = new AdditionalPageInfo();
            try
            {
                string sql = "select * from sy_pg_ctr where page_id = 'fc04458935360835'";

                //dsPageInfo = Hdd.GetDataTable(sql, "Page Controls");
                addinfo.CreateExpandedNotesSection(ref td_viewallnotes, Request.QueryString["PK"].ToString());
            }
            catch
            {

            }
            finally
            {
                Hdd = null;
                addinfo = null;
            }

        }

    }
    private void AddCancelButtons()
    {
        try
        {
            string url = Navigator.getURL(Request.Url.ToString());
            HtmlInputButton btncancel = new HtmlInputButton();
            btncancel.ID = "btn_cancel_top";
            btncancel.Value = "Cancel";
            btncancel.Attributes.Add("onclick", "javascript:disableThis('ctl00_ContentPlaceHolder3_btn_cancel_top','Cancelling...'); disableThis('ctl00_ContentPlaceHolder3_btn_cancel','Cancelling...'); window.location.href='" + url + "'");
            td_cancelheader.Controls.Add(btncancel);

            btncancel = new HtmlInputButton();
            btncancel.ID = "btn_cancel";
            btncancel.Value = "Cancel";
            btncancel.Attributes.Add("onclick", "javascript:disableThis('ctl00_ContentPlaceHolder3_btn_cancel_top','Cancelling...'); disableThis('ctl00_ContentPlaceHolder3_btn_cancel','Cancelling...'); window.location.href='" + url + "'");
            td_cancelbottom.Controls.Add(btncancel);
        }
        catch (Exception ex)
        {
            LogWriter.WriteLog("Error: AddCancelButtons : " + ex.Message);
        }
        finally
        {

        }


    }
    private string wrapItAsMessage(string msg, bool isError)
    {
        return "<div class=\"" + (isError == true ? "mbErrorMessage" : "mbMessage") + "\">" + msg + "</div>";
    }
}
